<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function Person(){}
        Person.prototype.head = 1;
        Person.prototype.foot = 2;
        Person.prototype.say = function() {
            console.log('我是一个人，我有'+this.head+'个头，还有'+this.foot+'个脚');
        }
        function Student(name, no) {
            this.name = name;
            this.no = no;
        }
        function extend(P,C) {
            // P父类 C子类
            var p = P.prototype;
            var c = C.prototype;
            // p 父类的原型对象  c子的原型对象
            for (var key in p) {
                c[key] = p[key];
            }
        }
        // extend这个函数执行完之后，Student中就已经有了Person的属性和方法
        extend(Person, Student);
        var zyl = new Student('张亚林', 007);
        console.log(zyl);
        zyl.say()
    </script>
</body>
</html>